//
//  CPYRankListTableViewCell.m
//  TTMusic
//
//  Created by chenpengyu on 16/4/3.
//  Copyright © 2016年 cpy. All rights reserved.
//

#import "CPYRankListTableViewCell.h"

@implementation CPYRankListTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.titleLable = [[TTMusicBaseLabel alloc] initWithFrame:CGRectZero];
        self.picImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.nameLable = [[TTMusicBaseLabel alloc] initWithFrame:CGRectZero];
        self.name1Lable = [[TTMusicBaseLabel alloc] initWithFrame:CGRectZero];
        self.name2Lable = [[TTMusicBaseLabel alloc] initWithFrame:CGRectZero];
        self.moreButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.moreButton setImage:[UIImage imageNamed:@"Image-rankMore"] forState:UIControlStateNormal];
        
        [self.contentView addSubview:self.name1Lable];
        [self.contentView addSubview:self.name2Lable];
        [self.contentView addSubview:self.moreButton];
        [self.contentView addSubview:self.picImageView];
        [self.contentView addSubview:self.nameLable];
        [self.contentView addSubview:self.titleLable];
        
    }
    return self;
}
- (void)layoutSubviews {
    self.picImageView.frame = CGRectMake(10, 10, self.bounds.size.width / 3, self.bounds.size.height - 10);
    self.titleLable.frame = CGRectMake(self.picImageView.bounds.size.width + 20, 10, self.bounds.size.width / 3, 21);
//    self.titleLable.textColor = [UIColor colorWithWhite:0.200 alpha:1.000];
    
    if ([UIScreen mainScreen].bounds.size.width > 320) {
        
        self.nameLable.frame = CGRectMake(self.picImageView.bounds.size.width + 20, 10 + self.titleLable.bounds.size.height, self.bounds.size.width / 3, 21);
        self.nameLable.font = [UIFont systemFontOfSize:12];
        
        self.name1Lable.frame = CGRectMake(self.picImageView.bounds.size.width + 20, 30 + self.nameLable.bounds.size.height, self.bounds.size.width / 3, 21);
        self.name1Lable.font = [UIFont systemFontOfSize:12];
        self.name2Lable.frame = CGRectMake(self.picImageView.bounds.size.width + 20, 53 + self.nameLable.bounds.size.height, self.bounds.size.width / 3, 21);
        self.name2Lable.font = [UIFont systemFontOfSize:12];
    } else {
        self.titleLable.font = [UIFont systemFontOfSize:15];
        self.nameLable.frame = CGRectMake(self.picImageView.bounds.size.width + 20, 10 + self.titleLable.bounds.size.height, self.bounds.size.width / 3, 21);
        self.nameLable.font = [UIFont systemFontOfSize:10];
        
        self.name1Lable.frame = CGRectMake(self.picImageView.bounds.size.width + 20, 36 + self.nameLable.bounds.size.height, self.bounds.size.width / 3, 21);
        self.name1Lable.font = [UIFont systemFontOfSize:10];
        self.name2Lable.frame = CGRectMake(self.picImageView.bounds.size.width + 20, 62 + self.nameLable.bounds.size.height, self.bounds.size.width / 3, 21);
        self.name2Lable.font = [UIFont systemFontOfSize:10];
    }
//    self.nameLable.textColor = [UIColor colorWithWhite:0.502 alpha:1.000];
//    self.name1Lable.textColor = [UIColor colorWithWhite:0.502 alpha:1.000];
//    self.name2Lable.textColor = [UIColor colorWithWhite:0.502 alpha:1.000];
    self.moreButton.frame = CGRectMake(self.bounds.size.width - 50, self.bounds.size.height / 2 - 10, 20, 20);
}
- (void)setRefsModel:(CPYRankListRefsModel *)refsModel {
    _refsModel = refsModel;
    [self.picImageView sd_setImageWithURL:[NSURL URLWithString:[refsModel.image objectForKey:@"pic"]]placeholderImage:[UIImage imageNamed:@"Image-p"]];
    
    self.titleLable.text = refsModel.title;
    
    CPYRankListSongModel *songsModel = refsModel.mutableArray[0];
    self.nameLable.text = [NSString stringWithFormat:@"1.%@-%@", songsModel.name, songsModel.singerName];
    CPYRankListSongModel *songsModel1 = refsModel.mutableArray[1];
    self.name1Lable.text = [NSString stringWithFormat:@"2.%@-%@", songsModel1.name, songsModel1.singerName];
    CPYRankListSongModel *songsModel2 = refsModel.mutableArray[2];
    self.name2Lable.text = [NSString stringWithFormat:@"3.%@-%@", songsModel2.name, songsModel2.singerName];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
